﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HuntTheWumpus
{
	public partial class GameForm : Form
	{
		public static GameControl gc;
		Button[] buttons;
		public GameForm()
		{
			InitializeComponent();
			buttons = new Button[6] { northB, northeastB, southeastB, southB, southwestB, northwestB };
			moveRB.Checked = true;
		}


		public void updateUI(int[] caveConnections, int arrows, int gold, int room)
		{
			for (int j = 0; j < 6; j++)
			{
				if (caveConnections[j] == -1)
				{
					buttons[j].Visible = false;
				}
				else
				{
					buttons[j].Visible = true;
					buttons[j].Text = caveConnections[j].ToString();
				}
			}
			goldL.Text = gold.ToString();
			arrowsL.Text = arrowsL.ToString();
			currentRoomL.Text = room.ToString();


		}
		private void northB_Click(object sender, EventArgs e)
		{
			buttonClick(int.Parse(northB.Text));
		}

		private void northwestB_Click(object sender, EventArgs e)
		{
			buttonClick(int.Parse(northwestB.Text));
		}

		private void northeastB_Click(object sender, EventArgs e)
		{
			buttonClick(int.Parse(northeastB.Text));
		}

		private void southeastB_Click(object sender, EventArgs e)
		{
			buttonClick(int.Parse(southeastB.Text));
		}

		private void southB_Click(object sender, EventArgs e)
		{
			buttonClick(int.Parse(southB.Text));
		}

		private void southwestB_Click(object sender, EventArgs e)
		{
			buttonClick(int.Parse(southwestB.Text));
		}

		public void buttonClick(int roomNumber)
		{
            
			if (moveRB.Checked)
			{
				GameControl.PlayerLocation = roomNumber;
				gc.move(roomNumber);
			}
			else
				gc.shoot(roomNumber);
            updateUI(GameControl.room, GameControl.mainPlayer.Arrow, GameControl.mainPlayer.Gold, GameControl.PlayerLocation);
		}
	}
}
